{% extends 'admin/layout.html.twig' %}

{% set menu = 'admin_live_course_manage' %}

{% set script_controller = 'course/live-lesson-search' %}

{% block main %}

{% if setting("course.live_course_enabled") == 1 %}

  {% include 'admin/live-course/tab.html.twig' %}
  <br>
  <form id="message-search-form" class="form-inline well well-sm mtl" action=" {{ path('admin_live_course', {status:status}) }}" method="get" novalidate>
    {% include 'org/org-tree-select.html.twig' with {orgCode: app.request.get('orgCode'), modal: 'list'} %}
    <div class="form-group">
      <select class="form-control" name="keywordType">
        {{ select_options({courseSetTitle:'admin.live_manage.name_option'|trans, taskTitle: 'admin.live_manage.task_option'|trans({'%taskName%':setting('course.task_name')|default('admin.setting_course.task'|trans)})}, app.request.get('keywordType')) }}
      </select>
    </div>
    <div class="form-group">
      <input class="form-control" type="text" placeholder="{{'admin.live_manage.keyword_placeholder'|trans}}" name="keyword" value="{{ app.request.get('keyword') }}">
    </div>
    <div class="form-group">
    {{'admin.live_manage.live_start_time_label'|trans}}：
    <input class="form-control" type="text" id="startDate" name="startDateTime" placeholder="{{'admin.live_manage.live_start_time_placeholder'|trans}}" value="{{ app.request.get('startDateTime') }}">
    <div class="form-group">-</div>
    <input class="form-control" type="text" id="endDate" name="endDateTime" placeholder="{{'admin.live_manage.live_end_time_placeholder'|trans}}" value="{{ app.request.get('endDateTime') }}">
    </div>
    <button class="btn btn-primary">{{'form.btn.search'|trans}}</button>
  </form>
  <input type="hidden" id="status" value="{{status}}">
  <table class="table table-striped table-hover" id="course-table">
    <thead>
    <tr>
      <th width="45%">{{ setting('course.task_name')|default('admin.setting_course.task'|trans) }}</th>
      {% include 'org/parts/table-thead-tr.html.twig' %}
      <th>{{'admin.live_manage.live_start_time_th'|trans}}</th>
      <th>{{'admin.live_manage.live_time_long_th'|trans}}</th>
      <th>{{'admin.live_manage.max_participate_count_th'|trans}}</th>
    </tr>
    </thead>
    <tbody>
      {% for liveTask in liveTasks %}
        {% set courseSet = courseSets[liveTask.fromCourseSetId]|default(null) %}
        {% include 'admin/live-course/tr.html.twig' %}
      {% else %}
        <tr><td colspan="20"><div class="empty">{{'admin.live_manage.empty'|trans}}</div></td></tr>
      {% endfor %}
    </tbody>
  </table>

  {{ admin_macro.paginator(paginator) }}
{% else %}
<div class="well" style="text-align:center;">

{% if eduCloudStatus == 'closed' %}
{{'admin.live_manage.edu_cloud_closed'|trans}}，<a href="{{ path('admin_my_cloud_overview') }}"> {{'admin.live_manage.show_detail'|trans}} </a>
{% endif %}
{% if eduCloudStatus == 'open' %}
  {{'admin.live_manage.cloud_live_closed'|trans}}，<a href="{{ path('admin_setting_cloud_edulive') }}"> {{'admin.live_manage.now_start'|trans}} </a>
{% endif %}
</div>
{% endif %}
{% endblock %}